<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
  x:Class="OpenLS.Spreadsheet.UI.SortStateResources" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:ss="http://schemas.Kherty.com/office/2007/spreadsheet"
  xmlns:ssui="clr-namespace:OpenLS.Spreadsheet.UI"
  >
  <DataTemplate DataType="{x:Type ss:SortCondition}">
    <Grid HorizontalAlignment="Stretch">
      <Grid.Resources>
        <ssui:SortByConverter x:Key="SortByConverter"/>
      </Grid.Resources>

      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <ComboBox Grid.Column="0" ItemsSource="{Binding Parent, Converter={StaticResource SortByConverter}}" SelectedIndex="{Binding Index}"/>
      <TextBlock Grid.Column="1" />
      <CheckBox Grid.Column="2" IsChecked="{Binding Descending}" Content="Descending"/>
    </Grid>
  </DataTemplate>
  <DataTemplate DataType="{x:Type ss:SortState}">
    <DockPanel LastChildFill="True">
      <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
        <Button Tag ="{Binding ElementName=listView}" Click="OnAddLevel">Add Level</Button>
        <Button Tag ="{Binding ElementName=listView}" Click="OnDeleteLevel">Delete Level</Button>
        <Button   Tag ="{Binding ElementName=listView}" Click="OnCopyLevel">Copy Level</Button>
        <Button Tag ="{Binding ElementName=listView}" Click="OnOptions">Options ...</Button>
        <CheckBox IsChecked="{Binding SortByColumn}"/>
      </StackPanel>
      <Grid DockPanel.Dock="Top">
        <Grid.Resources>
          <Style TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="0"/>
          </Style>
        </Grid.Resources>

        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Button Grid.Column="0">Column</Button>
        <Button  Grid.Column="1">Sort On</Button>
        <Button Grid.Column="2">Order</Button>
      </Grid>
      <ListBox ItemsSource="{Binding SortConditions}" Name ="listView" >
        <ListBox.ItemContainerStyle>
          <Style>
            <Setter Property="Control.HorizontalAlignment" Value="Stretch"/>
            <Setter Property="ListBoxItem.HorizontalContentAlignment" Value="Stretch"/>
          </Style>
        </ListBox.ItemContainerStyle>
      </ListBox>
    </DockPanel>
  </DataTemplate>
</ResourceDictionary>